<?php
	class Model_Comment extends CI_Model{
		private $comment_id=null;

		function __construct(){
			parent::__construct();
		}

		public function new_comment($title,$content){
			$student_id=$this->session->userdata("student_id");
			$release_time=date('y-m-d h:i:s');zzzz
			$data=array('student_id'=>$student_id,
				'title'=>$title,
				'content'=>$content,
				'release_time'=>$release_time,
				//'comment_id'=>$this->$comment_id,
				);
			$this->db->insert('comment',$data);
			if ($this->db->affected_rows()!=0) {
				return true;
			}else{
				return false;
			}

		}

		public function get_all_comment_info(){
			$this->db->select('comment_id,title,release_time,student_id');
			$query=$this->db->get('comment');
			$all_commet_array=$query->result_array();
			//replace the student_id with nick_name;
			foreach($all_commet_array as $item){
				$item['nick_name']=$this->Model_student->get_nick_name_id($item['student_id']);
				$nick_name_array[]=$item['nick_name'];
				$result_array[]=$item;
			}
			$all_commet_array=$result_array;
			return $all_commet_array;
		}

		public function show_comment(){


		}

		public function get_comment_by_id($comment_id){
			$this->db->select('*');
			$this->db->where('comment_id',$comment_id);
			$query=$this->db->get('comment');
			$result_array=$query->row_array();
			return $result_array;
		}

		public function show_one_commnet(){

		}

		public function reply_comment(){

		}
		
		public function delete_comment(){

		}

	}
?>
